import Joi from '@hapi/joi';
import { paginateRule } from './common';

export const indexRule = {
  query: {
    name: Joi.string().trim(),
    status: Joi.string(),
    order_id: Joi.string().trim().allow(''),
    transaction_id: Joi.string().trim().allow(''),
    user_id: Joi.string(),
    order_type: Joi.string(),
    ...paginateRule,
  },
};

export const detailRule = {
  params: {
    id: Joi.string(),
  },
};

export const readyRule = {
  body: {
    id: Joi.number(),
  },
};

export const sendRule = {
  body: {
    id: Joi.number(),
    shipper_id: Joi.string()
      .required(),
    shipper_name: Joi.string()
      .required(),
    shipper_code: Joi.string()
      .required()
  },
};

export const baseRule = {
  body: {
    id: Joi.number(),
  }
}


export const payRule = {
  body: {
    user_id: Joi.string().required(),
    people_number: Joi.number(),
    table_number: Joi.string(),
    order_type: Joi.string().required(),
    address_id: Joi.number(),
    note: Joi.string().allow(''),
  }
}

export const orderPayRule = {
  body: {
    order_id: Joi.string()
      .required(),
    user_id: Joi.string()
      .required(),
  }
}

export const numberRule = {
  body: {
    user_id: Joi.string().required(),
  }
}


export const refundRule = {
  body: {
    orderId: Joi.string()
      .required(),
    openId: Joi.string()
      .required(),
  }
}

export const submitRule = {
  body: {
    all_price: Joi.number()
      .required(),
    cart_id: Joi.string()
      .required(),
    user_id: Joi.string()
      .required()
  }
}

export const submitDetailRule = {
  query: {
    user_id: Joi.string()
      .required()
  }
}



